home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
e10_edit.arc
/
E.ASM
next >
Wrap
Assembly Source File
|
1990-03-22
|
63KB
|
2,401 lines
;E 1.0. Copyright (C) David Nye, 1990, all rights reserved.
;Assemble with TASM. Link: tlink /t e (makes a .COM file).
IDEAL
;Constants
LINEWIDTH EQU 80 ;Length of string storage for line
SCREENLENGTH EQU 24 ;Number of rows in display window
MAXLINES EQU 8096 ;Size of arrays of line pointers
BUFFERLENGTH EQU 1200h ;Length of file buffer
STACKSIZE EQU 50h ;Length of stack
BELL EQU 7 ;Some non-printing chars
BS EQU 8
HT EQU 9
LF EQU 10
CR EQU 13
CRLF EQU 0A0Dh
CTRL_Z EQU 26
ESCAPE EQU 27
DEL EQU 127
PROGLENGTH = EndOfProgram - Orig + 100h ;Length of .COM file
;Create a named string
MACRO String Name, Text
LOCAL LL
Name db LL-Name-1, Text
LL:
ENDM
;Make <Name> a byte ptr to <Length> bytes of storage after end of code.
;Like a .DATA? segment for .COM file, so uninitialized data doesn't take up
;room in the .COM file.
MACRO B? Name, Length
LOCAL where
where = EndOfProgram + BuffersCount
Name EQU BYTE PTR where
BuffersCount = BuffersCount + Length
ENDM
;Like B? but for word storage
MACRO W? Name, Length
LOCAL where
where = EndOfProgram + BuffersCount
Name EQU WORD PTR where
BuffersCount = BuffersCount + Length + Length
ENDM
BuffersCount = 0
MODEL TINY
CODESEG
ORG 100h
Orig:
jmp Start
String copyRight 'E 1.0. Copyright (C) David Nye, 1990. All rights reserved.'
;Some defaults, use Debug to change
colorAttributes dw 1770h ;Default status, text color video attributes
tabSize db 4 ;Tab increment
inserting? db -1 ;True if in insert mode
autoIndent? db -1 ;True if in autoindent mode
startInText? db 0 ;Set to true to start up in text mode
zLMargin db 8 ;Left margin setting for Alt Z
zRMargin db LINEWIDTH-8 ;Right margin setting for Alt Z
;Strings
String cantOpenMsg, "Can't open file."
String rdErrorMsg, 'Error reading file.'
String fileErrorMsg, 'File error.'
String noRoomMsg, 'Out of memory.'
String notMarkingMsg, 'Not marking.'
String setLabelMsg, 'Label (0-9): '
String setTabsMsg, 'Tab width: '
String newFileMsg, 'File name: '
String gotoMsg 'Jump to what line? '
String editingMsg <'Help F1',186,'Editing: '>
String findMsg 'Find: '
String replaceMsg 'Replace with: '
String notFoundMsg 'No more matching strings found.'
String anyKeyMsg 'Press any key to continue.'
String ctrlCMsg '*Break*'
String cancelledMsg 'Cancelled.'
BAK db '.BAK', 0
comspec$ db 'COMSPEC='
helpMsg db 'CURSOR left left arrow, ^S '
db 'BLOCK begin @B '
db ' right right arrow, ^D '
db ' copy block to buffer @C * '
db ' word left ^left arrow, ^A '
db ' delete block to buffer @D * '
db ' word right ^right arrow, ^F '
db ' insert block from buffer @I * '
db ' tab right, left Tab, Shift Tab '
db ' empty block buffer @E * '
db ' start, end of line Home, End '
db ' unmark @U '
db ' line up up arrow, ^E '
db 'FIND @F + '
db ' line down down arrow, ^X '
db ' replace @R + '
db ' page up PgUp, ^R '
db ' find/replace all @A + '
db ' page down PgDn, ^C '
db 'SAVE and continue @S '
db ' start of file ^PgUp '
db ' save and exit @X '
db ' end of file ^PgDn '
db ' kill (no save at exit) @K '
db 'DELETE Del '
db ' open another file @O '
db ' backspace Backspace '
db 'JUMP to line # @J '
db ' delete word left ^[ '
db ' set, goto label (0-9) @L, @G '
db ' delete word right ^], ^T '
db 'MARGIN set L, R ^Home, ^End '
db ' delete rest of line ^\ '
db ' wrap paragraph @W '
db ' delete line ^-, ^Y '
db ' set tabs @T '
db ' undelete line ^^ '
db ' toggle autoindent ^@ '
db 'INSERT mode toggle Ins '
db ' toggle text/prog mode @Z '
db ' insert raw char @= (+80h w shift) '
db 'SHELL to DOS, run EFn.BAT F2, F3-F6 * '
db 80 dup (' ')
db '@ = Alt, ^ = Ctrl, * = to/from file if s'
db 'hifted, + = use last string if shifted. '
db 'Status line flags: Insert Overwrite C'
db 'hanged AutoIndent [ LMargin ] RMargin'
;EXEC function parameter block
EXECParams dw 0
EXECCmdLineOff dw 0
EXECCmdLineSeg dw 0, -1, -1 , -1 , -1
EXECBAT db 0, '/c EF'
EXECFnumber db 'x.BAT '
EXECFileName db 20 dup (0)
;Variables
newFile? db 0 ;True if new file
marking? db 0 ;True if marking text
changed? db 0 ;True if original file has been changed
isBAKed? db 0 ;True if .BAK file already written
needCopies? db -1 ;True unless lines in buffer were just deleted
autoReplace? db 0 ;-1 if auto-replace with shift, 1 without shift
noEscape? db 0 ;True if prompt demands response
labelTable dw 10 dup (0) ;Table of line pointers assigned to labels
;These variables and buffers are allocated space following .COM file
W? sstack, STACKSIZE ;Stack goes here
STACKTOP = EndOfProgram + BuffersCount
B? attribNl, 1 ;Text and status line attributes
B? attribInv, 1
W? cursorShape, 1 ;Line cursor parameters for color or mono
B? fName?, 1 ;True if file name given on command line
B? justFound?, 1 ;True if no other commands since last Find
B? swapped?, 1 ;True if edited file swapped out during EXEC
W? lMargin, 1 ;Current margins
W? rMargin, 1
W? fHandle, 1 ;File handle
W? lastLine, 1 ;Index of last line in file
W? blockPtrsLast, 1 ;Index of last line in block buffer
W? top, 1 ;Index of first line on screen
W? bottom, 1 ;Index of last line on screen
W? mark, 1 ;Start of marking for block command
W? here, 1 ;Temporaries
W? spTemp, 1
W? comspecPtrOff, 1 ;Pointer to COMSPEC value: offset, segment
W? comspecPtrSeg, 1
W? bufferPtr, 1 ;Multipurpose buffer pointer
W? hereCol, 1
W? topSegPtr, 1
W? topSeg, 1
W? topIndex, 1
W? videoSegment, 1 ;Segment of system's video memory
W? heapStart, 1 ;Segment of start of heap
W? heapPtr, 1 ;Segment pointer to next free paragraph in heap
B? fName, 20 ;File name in ASCIIZ format
ESSENTIALS = BuffersCount ;Buffers above here not saved with shell + swap
B? fNameBAK, LINEWIDTH ;Current file with .BAK extension added
B? fNameTemp, LINEWIDTH ;File name for block read/writes, shell
B? pad, LINEWIDTH ;Scratch buffer
B? findString, LINEWIDTH ;Search string for Find command
B? replaceString, LINEWIDTH ;New string for Replace command
W? linePtrs, MAXLINES ;List of line pointers
W? blockPtrs, MAXLINES ;Line pointers for block or line deletes
B? buffer, BUFFERLENGTH ;File buffer
ENDFBUFFER = BuffersCount
;Jump tables: ^ = Ctrl, @ = Alt, # = Shift.
ctrlTable dw na ;Undefined
dw WordLeft ;^A
dw na ;^B
dw PageDown ;^C
dw Right ;^D
dw Up ;^E
dw WordRight ;^F
dw na ;^G or BEL
dw BackSpace ;^H or BS
dw Tab ;^I or HT
dw na ;^J or LF
dw na ;^K or VT
dw na ;^L or FF
dw CRet ;^M or CR
dw na ;^N or SO
dw na ;^O or SI
dw na ;^P
dw na ;^Q or DC1
dw PageUp ;^R or DC2
dw Left ;^S or DC3
dw DeleteWordR ;^T or DC4
dw na ;^U
dw na ;^V
dw na ;^W
dw Down ;^X or CAN
dw DeleteLine ;^Y
dw na ;^Z
dw DeleteWordL ;^[
dw DeleteToEOL ;^\
dw DeleteWordR ;^]
dw UndeleteLine ;^^
dw DeleteLine ;^-
auxTable dw 3 DUP (na) ;Undefined
dw AutoIndent ;^@ or NUL
dw 11 DUP (na) ;Undefined
dw ReverseTab ;#Tab
dw na ;@Q
dw Wrap ;@W
dw EmptyBuffer ;@E
dw Replace ;@R
dw SetTabs ;@T
dw na ;@Y
dw Unmark ;@U
dw InsertBlock ;@I
dw OtherFile ;@O
dw na ;@P
dw 4 DUP (na) ;Undefined
dw ReplaceAll ;@A
dw Save ;@S
dw DeleteBlock ;@D
dw Find ;@F
dw GotoLabel ;@G
dw Help ;@H
dw Jump ;@J
dw Kill ;@K
dw SetLabel ;@L
dw 5 DUP (na) ;Undefined
dw ToggleWPMode ;@Z
dw Exit ;@X
dw Copy ;@C
dw na